<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"
	import = "ass.beans.*"
	import = "ass.dao.*"
	import = "ass.dao.support.*"
	import = "java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Edit Profile</title>
</head>

<%
String username = (String) session.getAttribute("username");
UserDAO userDAO = new UserDAOImpl();
UserBean userBean = userDAO.getUser(username);

UserPrivacyDAO userPrivacyDAO= new UserPrivacyDAOImpl();
UserPrivacyBean userPrivacy = userPrivacyDAO.getUser(username);  


%>

<body>
	<%@ include file="header.html"%>
	<%@ include file="userNavBar.html"%>

	<div align="center">
	
	<%= (String) request.getAttribute("updated") == null ? "":(String) request.getAttribute("updated") %>
	
		<form name="form1" method="get" action="EditProfile">
			<table width="400" border="0">
				<tr>
					<td align="left">Username:</td>
					<td><%=username%> <br> <br> </td>
				</tr>
				<tr>
					<td align="left">First name:</td>
					<td><input name="fname" type="text" id="fname" size="30"
						maxlength="30" value="<%= userBean.getFirst_name()%>">
					</td>
					
				</tr>
				<tr>
					<td align="left">Last name:</td>
					<td><input name="lname" type="text" id="lname" size="30"
						maxlength="30" value="<%= userBean.getLast_name()%>"></td>
				</tr>
				<tr>
					<td align="left">Year of birth:</td>
					<td align="left"><select name="yselect" id="yselect">
							<% 
							
							out.print("<option value=\"null\">choose Year</option>");
							String selected = "";
							HashMap<String,String> a = new HashMap<String,String>();
							a.put(userBean.getYear_of_birth(), "selected");
	
							out.print("<option "+a.get("1980")+" value=\"1980\">1980</option>");
							out.print("<option "+a.get("1981")+" value=\"1981\">1981</option>");
							out.print("<option "+a.get("1982")+" value=\"1982\">1982</option>");
							out.print("<option "+a.get("1983")+" value=\"1983\">1983</option>");
							out.print("<option "+a.get("1984")+" value=\"1984\">1984</option>");
							out.print("<option "+a.get("1985")+" value=\"1985\">1985</option>");
							out.print("<option "+a.get("1986")+" value=\"1986\">1986</option>");
							out.print("<option "+a.get("1987")+" value=\"1987\">1987</option>");
							
							%>
					</select></td>
				</tr>
				<tr>
					<td align="left">Email:</td>
					<td><input name="email" type="text" id="email" size="30" value="<%= userBean.getEmail() %>"
						maxlength="30"></td>
				</tr>
				<tr>
					<td align="left">Favorite Actors and Actress:</td>
					<td align="left"><input type="text" name="favactor" value="<%= userBean.getFavourite_actors() %>"></td>
				</tr>
				<tr>
					<td align="left">Favorite Genre:</td>
					<td align="left"><select name="favselect" size="6" multiple
						id="favselect">
						
							<%
							String[] selectedGenre = userBean.getFavourite_genre().split(",");
							
							HashMap<String,String> selectedGenreHash = new HashMap<String,String>();
							
							for (String x: selectedGenre){
								selectedGenreHash.put(x, "selected");
							}
							
							%>
							<option <%= selectedGenreHash.get("Action") %> value="Action">Action</option>
							<option <%= selectedGenreHash.get("Comedy") %> value="Comedy">Comedy</option>
							<option <%= selectedGenreHash.get("Crime") %> value="Crime">Crime</option>
							<option <%= selectedGenreHash.get("Documentary") %> value="Documentary">Documentary</option>
							<option <%= selectedGenreHash.get("Romance") %> value="Romance">Romance</option>
							<option <%= selectedGenreHash.get("War") %> value="War">War</option>
					</select></td>
				</tr>
				
				<tr>
					<td><input type="submit" name="submit" id="submit"
						value="Submit"></td>
					<td align="left"></td>
				</tr>
			</table>
		</form>
	</div>

</body>
</html>